import Vue from 'vue'
import Router from 'vue-router'

import AppView from '@/components/app-view'
import Home from '@/pages/home'

Vue.use(Router)

const page = name => () => import('@/pages/' + name)

export default new Router({
  mode: 'history',
  routes: [
    {
      path: '',
      component: AppView,
      children: [
        {path: '/', name: 'home', component: Home},
        {path: '/404', name: '404', component: page('404')},
        {path: '/500', name: '500', component: page('500')},
        {path: '/analysis', name: 'analysis', component: page('analysis')},
        {path: '/driveGrade', name: 'driveGrade', component: page('driveGrade')},
        {path: '/drivingRecord', name: 'drivingRecord', component: page('drivingRecord')},
        {path: '/addTrack', name: 'addTrack', component: page('addTrack')},
        {path: '/editInfo', name: 'editInfo', component: page('editInfo')},
        {path: '/addViolation', name: 'addViolation', component: page('addViolation')}
      ]
    },
    {path: '/login', name: 'login', component: page('login')},
    {path: '/cnode', name: 'cnode', component: page('cnode')},
    // pages
    {path: '/home-login', name: 'p-login', component: page('home-login')},
    {path: '/register', name: 'p-register', component: page('register')},
    {path: '/keyboard', name: 'p-keyboard', component: page('c-keyboard')},
    {path: '*', redirect: {name: '404'}}
  ]
})
